package com.walleipt;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.w3c.dom.Element;

public class PigDefinitionParser extends AbstractSingleBeanDefinitionParser {

    @Override
    protected Class<?> getBeanClass(Element element) {
        return Pig.class;
    }

    @Override
    protected void doParse(Element element, BeanDefinitionBuilder builder) {

        String id = element.getAttribute("id") ;
        String name = element.getAttribute("name") ;
        Integer age = Integer.valueOf(element.getAttribute("age") ) ;
        builder.addPropertyValue("id",id ) ;
        builder.addPropertyValue("name", name ) ;
        builder.addPropertyValue("age", age ) ;
    }
}
